﻿namespace Cos.Module.CMS
{
    using System;
    using System.Collections.Generic;
    using Cos.Core.Exception;
    using Cos.Core.Model.Common;
    using Cos.Core.Model.Content;

    /// <summary>
    /// This Interface defines a list of methods to manage a page
    /// </summary>
    public interface IPageService
    {
        Nav GetNav(int navId);

        /// <summary>
        /// Get the page from page id.
        /// </summary>
        /// <typeparam name="T">The model class</typeparam>
        /// <param name="pageId">Id of the page.</param>
        /// <returns>a content page</returns>
        /// <exception cref="PageNotFoundException">If the page is not found</exception>
        Page GetPage(int pageId);
        
        /// <summary>
        /// Get the page from NavId and culture.
        /// </summary>
        /// <typeparam name="T">The target model class.</typeparam>
        /// <param name="cultureVo">Culture of the page.</param>
        /// <param name="navId">Id of the navigation.</param>
        /// <returns>a content page</returns>
        /// <exception cref="PageNotFoundException">If the page is not found</exception>
        Page GetPage(Culture cultureVo, int navId);
        
        /// <summary>
        /// Get a list of sub pages from a specific node.
        /// </summary>
        /// <typeparam name="T">The target model class.</typeparam>
        /// <param name="pageId">Id of the navigation.</param>
        /// <returns>a list of sub pages</returns>
        /// <exception cref="PageNotFoundException">If the page is not found</exception>
        IEnumerable<Page> GetSubPages(int pageId);
        
        /// <summary>
        /// Get a list of sub pages from a specific node
        /// </summary>
        /// <typeparam name="T">The target model class.</typeparam>
        /// <param name="cultureVo">Culture of the page.</param>
        /// <param name="navId">Id of the navigation.</param>
        /// <returns>a list of sub pages</returns>
        /// <exception cref="PageNotFoundException">If the page is not found</exception>
        IEnumerable<Page> GetSubPages(Culture cultureVo, int navId);
        
        /// <summary>
        /// Get a list of pages corresponding to a certain template.
        /// </summary>
        /// <param name="cultureVo">The culture of the page.</param>
        /// <returns>a list of pages</returns>
        IEnumerable<Page> GetPages(Culture cultureVo);

        /// <summary>
        /// Get a list of pages corresponding to a certain template.
        /// </summary>
        /// <param name="cultureVo">The culture of the page.</param>
        /// <param name="multiAssociationNavIds">The nav ids of the requested pages.</param>
        /// <returns>a list of pages</returns>
        IEnumerable<Page> GetPages(Culture cultureVo, string multiAssociationNavIds);
        
        /// <summary>
        /// Returns the first page that can be found of a certain template.
        /// </summary>
        /// <typeparam name="T">The model class.</typeparam>
        /// <param name="templateName">Name of the template.</param>
        /// <param name="cultureVo">The culture vo.</param>
        /// <returns>the model (if a page could be found)</returns>
        /// <exception cref="PageNotFoundException">If the page is not found</exception>
        Page GetFirstTemplatePage(string templateName, Culture cultureVo);

        IEnumerable<Page> GetTemplatePages(string templateName, Culture culture);

        Page SavePage(Nav nav, Page page, IEnumerable<Element> elements);

        Element GetElement(Culture culture, int navId, string partName);

        IEnumerable<Element> GetElements(int pageId);

        Element SaveElement(Element element);
    }
}